"""
现在给定一些身份证号码，请你验证校验码的有效性，并输出有问题的号码。
"""
zm = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
w = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
n = eval(input())
list1 = [input() for i in range(n)]
flag = 1
for i in range(len(list1)):
    sum1 = 0
    if not list1[i][:-1].isdigit():
        print(list1[i])
        flag = -1
        continue
    for j in range(len(list1[i])-1):
        sum1 += int(list1[i][j]) * w[j]
    z = sum1 % 11
    m = zm[z]
    if m != list1[i][-1]:
        print(list1[i])
        flag = -1
if flag > 0:
    print("All passed")

